package com.oa.entities.flows;

import com.oa.common.enums.PersonType;
import com.oa.domain.UndeleteEntity;
import com.oa.entities.User;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "oa_personnel_log")
public class PersonnelLog extends UndeleteEntity<Long> {
    /**
     *
     */
    private static final long serialVersionUID = -9172706983531043178L;

    /** 审核 人的名字 **/
    private String name;

    /** 审核人 **/
    private User audit;

    /** 审核人的id **/
    private Long auditId;

    /** 审核日期 **/
    private Long approvaldate;

    /** 批注 **/
    private String lnstructions;

    /**  审核状态 **/
    private int personType;

    /** 公文流转 **/
    private Personnel personnel;

    /** 公文流转id **/
    private Long personnelId;

    private Apps apps;

    private Long appsId;

    private AppType appType;

    private Long appTypeId;

    @Override
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return super.getId();
    }

    @Override
    public void setId(Long id) {
        super.setId(id);
    }

    @NotNull
    @Length(max = 32)
    @Column(name = "personnel_log_name",nullable = false)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "audit_id",nullable = false,updatable = false,insertable = false)
    public User getAudit() {
        return audit;
    }

    public void setAudit(User audit) {
        this.audit = audit;
    }

    @Column(name = "audit_id")
    public Long getAuditId() {
        return auditId;
    }

    public void setAuditId(Long auditId) {
        this.auditId = auditId;
    }

    @Column(name = "app_rovaldate",nullable = false)
    public Long getApprovaldate() {
        return approvaldate;
    }

    public void setApprovaldate(Long approvaldate) {
        this.approvaldate = approvaldate;
    }

    public String getLnstructions() {
        return lnstructions;
    }

    public void setLnstructions(String lnstructions) {
        this.lnstructions = lnstructions;
    }

    @Column(name = "person_type",nullable = false)
    public int getPersonType() {
        return personType;
    }

    public void setPersonType(int personType) {
        this.personType = personType;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "personnel_id",nullable = false,updatable = false,insertable = false)
    public Personnel getPersonnel() {
        return personnel;
    }

    public void setPersonnel(Personnel personnel) {
        this.personnel = personnel;
    }

    @Column(name = "personnel_id")
    public Long getPersonnelId() {
        return personnelId;
    }

    public void setPersonnelId(Long personnelId) {
        this.personnelId = personnelId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "apps_id",nullable = false,updatable = false,insertable = false)
    public Apps getApps() {
        return apps;
    }

    public void setApps(Apps apps) {
        this.apps = apps;
    }

    @Column(name = "apps_id")
    public Long getAppsId() {
        return appsId;
    }

    public void setAppsId(Long appsId) {
        this.appsId = appsId;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "app_type_id",updatable =false,insertable = false,nullable = false)
    public AppType getAppType() {
        return appType;
    }

    public void setAppType(AppType appType) {
        this.appType = appType;
    }

    @Column(name = "app_type_id")
    public Long getAppTypeId() {
        return appTypeId;
    }

    public void setAppTypeId(Long appTypeId) {
        this.appTypeId = appTypeId;
    }


    /**
     * 设置未审核
     */
    public void setUnAudited(){
        this.personType= PersonType.UNAUDITED.getCode();
    }

    /**
     * 设置已审核
     */
    public void setAudit(){
        this.personType= PersonType.AUDIT.getCode();
    }

    /**
     * 设置拒绝
     */
    public void setRefause(){
        this.personType= PersonType.REFUSE.getCode();
    }

    /**
     * 设置退回
     *
     */
    public void setReturn(){
        this.personType= PersonType.RETURN.getCode();
    }

}
